import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import '../lib/pages/test/test_demo.dart';

void main() {

  /// 测试类中的方法
  test("should return hello + something.", () {
    var string = MyTestDemo.greet('flutter');
    expect(string, "hello flutter");
  });

  /// 测试小部件
  testWidgets("widget testing demo", (WidgetTester tester) async {
    await tester.pumpWidget(
      MaterialApp(
        home: TestDemo()
      )
    );

    final labelTest = find.text("hello");
    // expect(labelTest, findsNothing);
    // expect(labelTest, findsOneWidget);
    expect(labelTest, findsNWidgets(1));

    final actionChipLabelText = find.text("0");
    expect(actionChipLabelText, findsOneWidget);

    final actionChip = find.byType(ActionChip);
    await tester.tap(actionChip);
    await tester.pump();

    final actionChipLabelTextAfterTap = find.text("1");
    expect(actionChipLabelTextAfterTap, findsOneWidget);
    expect(actionChipLabelText, findsNothing);
  });
}